<?php

function GenSQL_Get_Eng_Catename($str){
	$str=str_replace('/','-',$str);
	$str=str_replace(' ','-',$str);
	$str=preg_replace('#\s+#','',$str);
	$str=str_replace('--','-',$str);
	$str=str_replace('--','-',$str);
	return $str;
}


function GenSQL_Get_Name_To_Dir($typename) {
	if(IS_ENGLISH_BOOK){
		return GenSQL_Get_Eng_Catename($typename);
	}
	$arrVData['typename']=$typename;
    $arrEveryLetter = array();
    for ($i = 0; $i < mb_strlen($arrVData['typename'], 'UTF-8'); $i++) {
        $arrEveryLetter[] = mb_substr($arrVData['typename'], $i, 1, 'UTF-8');
    }
    global $globalUniqTypeDir;
    global $globalUniqKey;
    $strReturn = '';
    #只有一级分类
        if (in_array(ML_URL_TYPE, array(1))) {
            $strReturn.=h2p($arrVData['typename']);
        }
        if (in_array(ML_URL_TYPE, array(2))) {
            foreach ($arrEveryLetter as $strTopLetter) {
                $strReturn.=substr(h2p($strTopLetter), 0, 1);
            }
        }
        if (in_array($strReturn, $globalUniqTypeDir)) {
            $strReturn.=$globalUniqKey;
            $globalUniqKey++;
        }
        $globalUniqTypeDir[] = $strReturn;
        return $strReturn;

    if (in_array($strReturn, $globalUniqTypeDir)) {
        $strReturn.=$globalUniqKey;
        $globalUniqKey++;
    }
    $globalUniqTypeDir[] = $strReturn;
    return $strReturn;
}
?>